package com.xls.dormitoryservice.controller;


import com.xls.commonutils.Result;
import com.xls.dormitoryservice.entity.Department;
import com.xls.dormitoryservice.service.DepartmentService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/dormitory/department")
@Api(value = "楼栋信息接口")
@Slf4j
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @GetMapping("/departmentList")
    public Result<List<Department>> departmentList() {
        return Result.success(departmentService.departmentList());
    }

    @GetMapping("/majorList")
    public Result<List<Department>> majorList() {
        return Result.success(departmentService.majorList());
    }

    @GetMapping("/majorListById/{id}")
    public Result<List<Department>> majorListById(@PathVariable("id") String id) {
        return Result.success(departmentService.majorListById(id));
    }

    @GetMapping("/department/{id}")
    public Result<Department> department(@PathVariable("id") String id) {
        return Result.success(departmentService.department(id));
    }

    @GetMapping("/major/{id}")
    public Result<Department> major(@PathVariable("id") String id) {
        return Result.success(departmentService.major(id));
    }

}

